
import json
import requests
import ai_service.ai_service_kimi as ai_kimi
import ai_service.app_service_feishu as ai_feishu

ai_kimi_service = ai_kimi.createServiceKimi()
ai_feishu_service = ai_feishu.createServiceFeishu()

class DutyService:
    def __init__(self):
        pass

    def parse_duty(self, text):
        print("Parsing duty text... %s" % text)
        result = ai_kimi_service.parse_duty(text)
        print(result)
        ai_feishu_service.update_duty_data(result)
        return result

    def feishu_test(self):
        # ai_feishu_service.request_token()
        result = '[ \
    { \
        "class": "数学作业",\
        "time": 1675934720000,\
        "duty": "计算26页"\
    },\
    {\
        "class": "数学作业",\
        "time": 1675934720000,\
        "duty": "订正知训，第三单元基础过关"\
    }\
]'
        return ai_feishu_service.update_duty_data(result)

    def query_data(self, date, limit):
        return "No data"

def createDutyService(service_id = 1):
    if (service_id == 1):
        service = DutyService()
        return service
    return None
